package it.uniroma2.dtk.dt;

/**
 * @author lorenzo
 * Concretization of the DefaultAbstractDT, providing the shuffled gamma-product 
 * and the shuffled circular convolution as implementations of the ideal composition function
 */
public class GenericDT extends DefaultAbstractDT {

	public enum Types {PRODUCT, CONVOLUTION};
	
	private Types type;
	
	public GenericDT(int randomOffset, int vectorsSize, boolean usePos, boolean lexicalized, Types type) throws Exception {
		super(randomOffset, vectorsSize, usePos, lexicalized);
		this.type = type;
	}
	
	public GenericDT(int randomOffset, int vectorsSize, boolean usePos, boolean lexicalized, int type) throws Exception {
		this(randomOffset, vectorsSize, usePos, lexicalized, Types.values()[type]);
	}
	
	public GenericDT(int randomOffset, int vectorsSize, boolean usePos, boolean lexicalized, String type) throws Exception {
		this(randomOffset, vectorsSize, usePos, lexicalized, Types.valueOf(type));
	}

	@Override
	public double[] op(double[] v1, double[] v2) throws Exception {
		switch (type) {
		case PRODUCT: return vectorComposer.shuffledGammaProduct(v1, v2);
		case CONVOLUTION: return vectorComposer.shuffledConvolutionFFT(v1, v2);
		default: throw new Exception("Unknown CDS type:" + type);
		}
	}
	
	public Types getType() {
		return type;
	}

}
